package com.hnxxxy.common.shiro;

import lombok.Setter;
import org.apache.shiro.cache.AbstractCacheManager;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @CLASSDESCRIPER:
 * @AUTHOR:suhui
 * @PHONE:13319575368
 * @EMIAL:13319575368@163.COM
 * @DATE: 2020/5/9
 * @PARAMDESCRIPER:
 * @OUTPARAMDESCRIPER:
 */
@Setter
public class MyShiroCacheManager extends AbstractCacheManager {
    private RedisTemplate<String,Object> templateRedis;
    /**
     * @Description:   当shiro中需要缓存数据(身份数据，权限数据)，都会需要一个CacheManager
     * CacheManager,核心工作之一：创建一个缓存对象
     * @Author: SUHUI
     * @EMAIL:13319575368@163.COM
     * @Date: 2020/5/9 2:28
     * @ACTION:
     * @param s:权限信息的标识字符串
     * @return: org.apache.shiro.cache.Cache
     **/
    @Override
    protected Cache createCache(String s) throws CacheException {
        MyShiroCache  cache =new MyShiroCache(s);
        cache.setTemplateRedis(templateRedis);
        return cache;
    }
}
